<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<ui:composition 
	template="/template/template-controle.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">
	
	<ui:define name="titulo">Manter eventos</ui:define>	
	
	<ui:define name="corpo">
		
		<br/>
		
		<div class="container" style="width:1150px;">
		
			<h:form id="loginForm">
			
				<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
				<script type="text/javascript" src="http://jquery-joshbush.googlecode.com/files/jquery.maskedinput-1.2.1.pack.js"></script>
				<script type="text/javascript" src="#{facesContext.externalContext.requestContextPath}/js/jquery/jquery.maskMoney.js"></script>
				
				<script type="text/javascript">
	
					jQuery(function(){
						jQuery('input[id*="nome"]').focus();
						jQuery('input[id*="dataEvento"]').mask("99/99/9999");
					});
					
				</script>
				
				<h3 align="left">Controle de eventos</h3>
				<div align="center" style="position: relative;"> <hr align="center" style=" height: 01px;" class="btn-danger sombra"/></div>
				
				<h6>Os campos que contém o " <span style="color: red; font-size: 15px;">*</span> " são obrigatórios.</h6>
				
				<div class="control-group error">
					<table cellspacing="10" width="700px">
						<tr>
							<td>
								<h4><span style="color: red; font-size: 15px;" >*</span> Nome:</h4>
								<p:inputText 
									id="nome" 
									value="#{manterEventoBean.evento.nmEvento}"
									maxlength="100" 
									style="width:220px;" />
				            </td>
						</tr>
						<tr>
				            <td>
				            	<h4><span style="color: red; font-size: 15px;" >*</span> Data do evento:</h4>
								<p:inputText  
									id="dataEvento"
									value="#{manterEventoBean.evento.dataEvento}" 
		                        	maxlength="70" 
		                        	style="width:200px;" />
				            </td>
						</tr>
						<tr>
				            <td>
				            	<h4><span style="color: red; font-size: 15px;" >*</span> Local:</h4>
								<p:inputText  
									id="local"
									value="#{manterEventoBean.evento.local}"
									maxlength="50"
									style="width:150px;">
								</p:inputText>
								
				            </td>
						</tr>
						<tr>
				            <td>
								<h4><span style="color: red; font-size: 15px;" >*</span> Inscrição:</h4>
								<p:inputText  
									id="inscricao"
									value="#{manterEventoBean.evento.inscricao}"
									maxlength="50"
									style="width:150px;">
								</p:inputText>
								
				            </td>
						</tr>
						<tr>
				            <td>
								<h4><span style="color: red; font-size: 15px;" >*</span> Descrição:</h4>
								<p:inputTextarea 
									id="descricao"
									style="width:400px;"
									value="#{manterEventoBean.evento.descricao}"
									rows="10" 
									cols="50" 
									maxlength="500"/> 
				            </td>
						</tr>
					</table>
				</div>
			
				<br />
				
				<div align="left">
					
					<p:commandButton 
						styleClass="btn btn-danger sombra"
						id="botaoSalvar" 
						value="Cadastrar"
						action="#{manterEventoBean.salvarEvento}" 
						update="msgSistema, loginForm, listaParticipante" 
						ajax="false" 
						style="margin-left:5px;"> 
					</p:commandButton>	
					
					<p:commandButton 
						styleClass="btn btn-danger sombra"
						id="botaoLimpar" 
						value="Limpar"
						action="#{manterEventoBean.limparCampos}" 
						update=":msgSistema, :loginForm" 
						ajax="false" 
						style="margin-left:5px;">
					</p:commandButton>
				</div>
			</h:form>
			
			<br/>
			
			<h3 align="left">Lista de eventos cadastrados</h3>
			<div align="center" style="position: relative;"> <hr align="center" style=" height: 01px;" class="btn-danger sombra"/></div>
			
			<h:form id="listaParticipante" styleClass="sombra">
				<p:dataTable 
					id="listaCadastroParticipante" 
					var="evento"
					paginator="true" 
					rows="10" 
					paginatorPosition="bottom"
					value="#{manterEventoBean.todosEvento}"
					emptyMessage="Nenhum evento encontrado">
	
					<p:column 
						style="width:300px;"
						filterBy="#{evento.nmEvento}"
						headerText="Nome" filterMatchMode="contains">
						<h:outputText value="#{evento.nmEvento}" />
					</p:column>
					
					<p:column  
						filterBy="#{evento.dataEvento}"
						headerText="Data Evento" filterMatchMode="contains">
						<h:outputText value="#{evento.dataEvento}"/>
					</p:column>
					
					<p:column  
						filterBy="#{evento.inscricao}"
						headerText="Inscrição" filterMatchMode="contains">
						<h:outputText value="#{evento.inscricao}" />
					</p:column>
					
					<p:column  
						style="width:600px;"
						filterBy="#{evento.descricao}"
						headerText="Descrição" filterMatchMode="contains">
						<h:outputText value="#{evento.descricao}" />
					</p:column>
					
					<p:column 
						style="width:130px;"
						headerText="Ações">
					
						<p:commandButton 
							update=":loginForm"
							image="ui-icon ui-icon-pencil" 
							immediate="true">
							<f:setPropertyActionListener 
								value="#{evento}"
								target="#{manterEventoBean.evento}" />
						</p:commandButton>
					
						<p:commandButton 
							oncomplete="confirmation.show()"
							image="ui-icon ui-icon-trash" 
							immediate="false">
							<f:setPropertyActionListener 
								value="#{evento}"
								target="#{manterEventoBean.eventoAux}" />
						</p:commandButton>
					</p:column>
				</p:dataTable>
				
				<p:confirmDialog 
					message="Deseja excluir o registro?"
					widgetVar="confirmation">
					<div align="center">
						
						<p:commandButton 
							value="Sim"
							update=":msgSistema, :listaParticipante"
							oncomplete="confirmation.hide()" 
							immediate="true"
							actionListener="#{manterEventoBean.exluirEvento}">
						</p:commandButton>
						
						<p:commandButton 
							value="Não" 
							update=":msgSistema, :listaParticipante"
							onclick="confirmation.hide()"
							immediate="true"
							actionListener="#{manterEventoBean.limparCampos}">
						</p:commandButton>
					</div>
				</p:confirmDialog>
			</h:form>
		</div>	
	</ui:define>
</ui:composition>